/**
 * Created by WHD on 2017/5/25.
 */


myapp.filter('myDateFormat', function(){
    return function(data){

        return jsDate(data);

        function jsDate(pTime){
            var d_minutes,d_hours,d_days,d;
            var timeNow = parseInt(new Date().getTime()/1000);

            pTime_new = new Date(pTime).getTime()/1000;

            d = timeNow - pTime_new;
            d_days = parseInt(d/86400);
            d_hours = parseInt(d/3600);
            d_minutes = parseInt(d/60);
            if(d_days>0 && d_days<30){
                return d_days+"天前";
            }else if(d_days<1 && d_hours>0){
                return d_hours+"小时前";
            }else if(d_hours<1 && d_minutes>0){
                return d_minutes+"分钟前";
            }else if(d_minutes<1){
                return '刚刚';
            }else{
                return pTime;
            }
        }
    }
})